﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Globalization;

namespace WowGuildSite.Armory
{
    public enum CombatStatType
    {
        MainHand,
        OffHand,
        Ranged,
    }

    public class ArmoryCombatStat
    {
        private CombatStatType              type;
        private decimal                     speed;
        private decimal                     dps;
        private int                         minDamage;
        private int                         maxDamage;
        private int                         skill;

        public CombatStatType               Type
        {
            get { return type; }
        }

        public decimal                      Dps
        {
            get { return dps; }
        }

        public decimal                      Speed
        {
            get { return speed; }
        }

        public int                          MinDamage
        {
            get { return minDamage; }
        }

        public int                          MaxDamage
        {
            get { return maxDamage; }
        }

        public int                          Skill
        {
            get { return skill; }
        }

        internal static ArmoryCombatStat    FromElement(XmlElement damageElement,XmlElement skillElement )
        {
            if ( damageElement == null || skillElement == null )
            {
                return new ArmoryCombatStat();
            }

            ArmoryCombatStat combatStat = new ArmoryCombatStat();

            switch (damageElement.Name)
            {
                case "damage":
                    combatStat.type = CombatStatType.Ranged;
                    break;
                case "mainHandDamage":
                    combatStat.type = CombatStatType.MainHand;
                    break;
                case "offHandDamage":
                    combatStat.type = CombatStatType.OffHand;
                    break;
            }

            combatStat.minDamage    = ArmoryXmlUtility.GetElementAttributeInt(damageElement, "min");
            combatStat.maxDamage    = ArmoryXmlUtility.GetElementAttributeInt(damageElement, "max");
            combatStat.dps          = ArmoryXmlUtility.GetElementAttributeDecimal(damageElement, "dps");
            combatStat.speed        = ArmoryXmlUtility.GetElementAttributeDecimal(damageElement, "speed");
            combatStat.skill        = ArmoryXmlUtility.GetElementAttributeInt(skillElement, "value");

            return combatStat;
        }

        private ArmoryCombatStat()
        {
        }
    }
}
